﻿-- ================================================
-- Remarks: 
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS ( SELECT  * FROM sysobjects WHERE type = 'P' AND name = 'Ivy_Feedback_GetByCriteria' ) 
    BEGIN
        DROP  PROCEDURE  Ivy_Feedback_GetByCriteria
    END

GO

CREATE PROCEDURE [Ivy_Feedback_GetByCriteria] 
-- =============================================
-- Author:		<Kambui Nurse>
-- Create date: <8/25/2012>
-- Description:	<Ivy_Feedback_GetByCriteria>
-- =============================================
-- Add the parameters for the stored procedure here
    (
      @FeedbackText VARCHAR(MAX) = NULL ,
      @FeedbackDate DATETIME = NULL ,

      @Sys_DateOfCreation DATETIME = NULL ,
      @Sys_DateOfModification DATETIME = NULL ,
      @Sys_CreatedByID VARCHAR(50) = NULL ,
      @Sys_ModifiedByID VARCHAR(50) = NULL ,
      @Sys_DeleteType INT = NULL ,
      @Sys_IsDeleted INT = NULL ,
      @Sys_OrganizationID INT = NULL ,
      @Sys_InitialPrimaryKeys VARCHAR(MAX) = NULL ,
      @Sys_WorkstationName VARCHAR(50) = NULL

	)
AS 
    BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
        SET NOCOUNT OFF;

        SELECT  [FeedbackKey] ,
                [FeedbackUserKey] ,
                [FeedbackText] ,
                [FeedbackDate] ,

                [Sys_DateOfCreation] ,
                [Sys_DateOfModification] ,
                [Sys_CreatedByID] ,
                [Sys_ModifiedByID] ,
                [Sys_DeleteType] ,
                [Sys_IsDeleted] ,
                [Sys_OrganizationID] ,
                [Sys_InitialPrimaryKeys] ,
                [Sys_WorkstationName]
        FROM    [Feedback]
        WHERE   ( 
					@FeedbackText = ISNULL(@FeedbackText, [FeedbackText]) AND
					@FeedbackDate = ISNULL(@FeedbackDate, [FeedbackDate]) AND 
				
					@Sys_DateOfCreation = ISNULL(@Sys_DateOfCreation, [Sys_DateOfCreation]) AND
					@Sys_DateOfModification = ISNULL(@Sys_DateOfModification, [Sys_DateOfModification]) AND
					@Sys_CreatedByID = ISNULL(@Sys_CreatedByID, [Sys_CreatedByID]) AND
					@Sys_ModifiedByID = ISNULL(@Sys_ModifiedByID, [Sys_ModifiedByID]) AND 
					@Sys_DeleteType = ISNULL(@Sys_DeleteType, [Sys_DeleteType]) AND
					@Sys_IsDeleted = ISNULL(@Sys_IsDeleted, [Sys_IsDeleted]) AND
					@Sys_OrganizationID = ISNULL(@Sys_OrganizationID, [Sys_OrganizationID]) AND
					@Sys_InitialPrimaryKeys = ISNULL(@Sys_InitialPrimaryKeys, [Sys_InitialPrimaryKeys]) AND
					@Sys_WorkstationName = ISNULL(@Sys_WorkstationName, [Sys_WorkstationName])
				);
    END
  GO
